<? session_start();
						
include_once ('core/conn.php');
						
$db = get_conn();
						
check_session();
						
if($_GET['id'] != ''){
							
	$sql = " select * from invoices_type where id_it=".$_GET['id']; 
							
	$result = mysql_query($sql);	
							
	if($result){
								
		$row = mysql_fetch_array($result);
		$id_it = $row['id_it'];
		$name = $row['name'];
		$code = $row['code'];
		$bank_acc = $row['bank_acc'];
		$bank_acc_owner = $row['bank_acc_owner'];
		$base_amount = $row['base_amount'];
							
	}else{
								
		error_handling($sql,mysql_error());
							
	}
						
}
						
						
					
?>
					
					
<html>
					
<head>
					
					

				
				
<script>
					
<!--
						
	function checkdata(obj){
							
		if(obj.id_it.value ==''){
								
			alert('Please fill the id_it');
								
			obj.id_it.focus();
								
			return false;
							
		}
							
		if(isNaN(obj.id_it.value) ){
								
			alert('id_it must be a number');
								
			obj.id_it.focus();
								
			return false;
							
		}				
						
							
		if(obj.name.value ==''){
								
			alert('Please fill the name');
								
			obj.name.focus();
								
			return false;
							
		}
							
		if(obj.code.value ==''){
								
			alert('Please fill the code');
								
			obj.code.focus();
								
			return false;
							
		}
							
		if(obj.bank_acc.value ==''){
								
			alert('Please fill the bank_acc');
								
			obj.bank_acc.focus();
								
			return false;
							
		}
							
		if(obj.bank_acc_owner.value ==''){
								
			alert('Please fill the bank_acc_owner');
								
			obj.bank_acc_owner.focus();
								
			return false;
							
		}
							
		if(obj.base_amount.value ==''){
								
			alert('Please fill the base_amount');
								
			obj.base_amount.focus();
								
			return false;
							
		}
							
		if(isNaN(obj.base_amount.value) ){
								
			alert('base_amount must be a number');
								
			obj.base_amount.focus();
								
			return false;
							
		}				
						
	return true;
						
	}
					
-->
					
</script>
					
</head>									
					
<body>														
				
				
<form name='invoices_type' method='post' action='/core/invoices_type.php' onsubmit='return checkdata(this)'>
				
<table width='100%' border='0'>
				  
	<tr>
	  <td valign='top'><a href="invoices_types_form.php">Crear Nuevo Tipo</a></td>
    </tr>
	<tr>
					
		<td valign='top'>
		  
		  <? 
			
		$sql = "select  * from invoices_type order by name";
			
		$result = mysql_query($sql);
			
		if($result){
				
			$data ="<table width='100%'>";
			$data .="<tr>
				<td align='left' >
					Codigo
				</td>											
				<td align='left' >
					Nombre
				</td>
				<td align='left' >
					Monto Base
				</td>						
				</tr>";				
			if(mysql_num_rows($result) > 0){
					
				while($row = mysql_fetch_array($result)){
						
					$data .="<tr>
						<td align='left' >
							<a href='invoices_types_form.php?id=".$row['id_it']."'>".$row['code']."</a>
						</td>											
						<td align='left' >
							<a href='invoices_types_form.php?id=".$row['id_it']."'>".$row['name']."</a>
						</td>
						<td align='left' >
							<a href='invoices_types_form.php?id=".$row['id_it']."'>".$row['base_amount']."</a>
						</td>						
						</tr>";
					
				}//while
				
			}//if
				
			else{
					
				$data .= "<tr><td align='center'>No hay invoices_type registrados</td></tr>";			
				
			}
				
			$data .="</table>";
			
		}else{
				
			error_handling($sql,mysql_error());
			
		}
			
		echo $data;
			
		?>&nbsp;</td>
						
	</tr>
					
</table>
</form>
					
</body></html>													
					